<template>
  <div class="table-container">
    <el-table
      :key="tablekey"
      v-loading="listLoading"
      :data="list"
      border
      fit
      highlight-current-row
      style="width:100%"
    >
      <el-table-column label="序号" prop="id" align="center" width="120px">
        <template slot-scope="{ row }">
          <span>{{ row.id }}</span>
        </template>
      </el-table-column>
      <el-table-column label="名称" min-width="150px">
        <template slot-scope="{ row }">
          <span class="link-type" >{{
            row.name
          }}</span>
        </template>
      </el-table-column>
      <el-table-column label="性别" min-width="100px">
        <template slot-scope="{ row }">
          <span class="link-type">{{ row.sex }}</span>
        </template>
      </el-table-column>
      <el-table-column label="民族" width="110px" align="center">
        <template slot-scope="{ row }">
          <span>{{ row.patent}}</span>
        </template>
      </el-table-column>
       <el-table-column label="身份证号" width="110px" align="center">
        <template slot-scope="{ row }">
          <span>{{ row.idnumber }}</span>
        </template>
      </el-table-column>
       <el-table-column label="学籍号" width="110px" align="center">
        <template slot-scope="{ row }">
          <span>{{ row.xjh }}</span>
        </template>
      </el-table-column>
       <el-table-column label="学籍辅号" width="110px" align="center">
        <template slot-scope="{ row }">
          <span>{{ row.xjfh }}</span>
        </template>
      </el-table-column>
       <el-table-column label="家庭住址" width="110px" align="center">
        <template slot-scope="{ row }">
          <span>{{ row.citys }}{{row.cityq}}{{row.cityx}}</span>
        </template>
      </el-table-column>
       <el-table-column label="详细地址" width="110px" align="center">
        <template slot-scope="{ row }">
          <span>{{ row.address }}</span>
        </template>
      </el-table-column>
       <el-table-column label="户籍所在地" width="110px" align="center">
        <template slot-scope="{ row }">
          <span>{{ row.hjaddress}}</span>
        </template>
      </el-table-column>
       <el-table-column label="就读小学名称" width="110px" align="center">
        <template slot-scope="{ row }">
          <span>{{ row.schollname }}</span>
        </template>
      </el-table-column>
       <el-table-column label="父亲姓名" width="110px" align="center">
        <template slot-scope="{ row }">
          <span>{{  row.fathername}}</span>
        </template>
      </el-table-column>
       <el-table-column label="母亲姓名" width="110px" align="center">
        <template slot-scope="{ row }">
          <span>{{ row.mathername }}</span>
        </template>
      </el-table-column>
       <el-table-column label="联系电话" width="110px" align="center">
        <template slot-scope="{ row }">
          <span>{{ row.phone }}</span>
        </template>
      </el-table-column>
       <el-table-column label="备用联系电话" width="110px" align="center">
        <template slot-scope="{ row }">
          <span>{{ row.bfphone }}</span>
        </template>
      </el-table-column>
       <el-table-column label="性别" width="110px" align="center">
        <template slot-scope="{ row }">
          <span>{{ row.type.typename }}</span>
        </template>
      </el-table-column>
       <el-table-column label="性别" width="110px" align="center">
        <template slot-scope="{ row }">
          <span>{{ row.type.typename }}</span>
        </template>
      </el-table-column>
      <el-table-column label="创建时间" width="170px" align="center">
        <template slot-scope="{ row }">
          <span>{{ row.createdAt | formtTime }}</span>
        </template>
      </el-table-column>
      <el-table-column label="修改时间" width="170px" align="center">
        <template slot-scope="{ row }">
          <span>{{ row.updatedAt | formtTime }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="操作"
        align="center"
        width="230px"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="{ row, $index }">
         
          <el-button
            type="danger"
            size="mini"
            @click="handleDelete(row, $index)"
          >
            删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { formtTime } from "@/utils/tools";
export default {
  name: "Table",
  props: {
    tablekey: Number,
    listLoading: Boolean,
    list: Array
  },
  filters: {
    formtTime
  },
  mounted(){
    console.log(this.list);
  },
  methods: {
    
    handleDelete(row, index) {
      this.$emit("handleDelete", row, index);
    }
  }
};
</script>

<style>
.table-container {
  padding: 10px 20px 20px 20px;
}
</style>